Use the pan manipulator to enable users to move nodes in your Kanzi application. For example, you can use the pan manipulator to enable users to move a map. See Enabling the pan gesture for a node.
Use the Pan Manipulator triggers to react to the pan gesture. For example, you can set the appearance of a node when the user pans that node. See Using the Pan Manipulator triggers.
The pan manipulator is one of the input manipulators you can use to add gesture recognition to nodes in your Kanzi application. You can assign the input manipulators through the Kanzi Engine API. See Using input manipulators.
Learn how to use the pan manipulator by completing a tutorial. See Tutorial: Pan, zoom, tap.
To enable the pan gesture for a node:



# sign followed by the name of the alias.


private:
// Define the handler for the PanManipulator::StartedMessage message from 2D nodes
// that have an input manipulator which generates pan messages.
// This handler prepares a 2D node for a pan gesture.
void onPanStarted(PanManipulator::StartedMessageArguments& messageArguments)
{
// Get from the message arguments the node that the user pans.
Node2DSharedPtr node2d = dynamic_pointer_cast<Node2D>(messageArguments.getSource());
if (!node2d)
{
return;
}
// When starting a pan gesture on the node, bring the node to front.
node2d->moveToFront();
}
// Define the handler for the PanManipulator::MovedMessage message from 2D nodes
// that have an input manipulator which generates pan messages.
// This handler translates a 2D node by the amount of the pan gesture.
void onPanMoved(PanManipulator::MovedMessageArguments& messageArguments)
{
// Get from the message arguments the node that the user pans.
Node2DSharedPtr node2d = dynamic_pointer_cast<Node2D>(messageArguments.getSource());
if (!node2d)
{
return;
}
// Get the distance in pixels that the pan has progressed
// since the last message in the pan gesture sequence.
Vector2 translationDelta = messageArguments.getDelta();
// Get the Render Transformation property of the node.
SRTValue2D nodeTransform = node2d->getRenderTransformation();
// Get the size of the node.
Vector2 nodeSize = node2d->getActualSize();
// Get the current translation of the node.
Vector2 translation = nodeTransform.getTranslation();
// Apply the translation from the pan message.
Vector2 translationTarget = translation - translationDelta;
// Set the new translation.
nodeTransform.setTranslation(translationTarget);
// Apply the new transform to the node.
node2d->setRenderTransformation(nodeTransform);
}onProjectLoaded() function create a PanManipulator manipulator and subscribe to its messages.
virtual void onProjectLoaded() KZ_OVERRIDE
{
ScreenSharedPtr screen = getScreen();
Domain* domain = getDomain();
// Get the PanNode using its alias.
NodeSharedPtr panNode = screen->lookupNode<Node>("#PanNode");
// Create an input manipulator that generates pan messages.
PanManipulatorSharedPtr panManipulator = PanManipulator::create(domain);
// Set the threshold in pixels on the horizontal and vertical axis that the finger
// or mouse has to move before the input manipulator recognizes the pan gesture.
panManipulator->setRecognitionThreshold(Vector2(10.0f, 10.0f));
// Add the input manipulator to the PanNode.
panNode->addInputManipulator(panManipulator);
// Subscribe to the PanManipulator::StartedMessage message at the PanNode.
// The PanManipulator generates this message when the user clicks or touches the attached node.
panNode->addMessageHandler(PanManipulator::StartedMessage, bind(&MyProject::onPanStarted, this, placeholders::_1));
// Subscribe to the PanManipulator::MovedMessage message at the PanNode.
// The PanManipulator generates this message initially when the user moves their finger or mouse
// on the horizontal or vertical axis more than the recognition threshold, and after that
// when the finger or mouse has moved between updates.
panNode->addMessageHandler(PanManipulator::MovedMessage, bind(&MyProject::onPanMoved, this, placeholders::_1));
}Use the Pan Manipulator triggers to react to the pan gesture. For example, you can set the appearance of a node when the user pans that node.
The Pan Manipulator has these triggers:
To use the Pan Manipulator triggers:



For details, see the PanManipulator class in the API reference.